package com.seven.restaurant.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger-ui的配置类
 * @author BaiBan
 * @since 2022/7/21
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false) // 去除默认返回结果
                .apiInfo(apiInfo()).enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.seven.restaurant.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    // 团队信息
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("餐厅点餐系统-API文档")
                .contact(new Contact("图灵车队", "", ""))
                .description("实训项目")
                .build();
    }
}